Ext.onReady(function () {
	Ext.Loader.setConfig({
	   enabled: true,
	   paths : {
	      'JRainbow.pages' : 'js/pages'
	   }
	});

	var north = new Ext.Panel({
        id: 'north',
        autoWidth: true,
        heigth: 400,
        frame: true,
        region: 'north',
        html: '<div style="background-color:#157FCC;font-size:40px;">JRainbow System</div>'
    });
    var west = new JRainbow.common.LeftMenu({
        id: 'west',
        title: '菜单栏',
        width: 200,
        heigth: 'auto',
        split: true, //显示分隔条
        region: 'west',
        collapsible: true,
        listeners : {
			'itemclick' : function(view, record) {
				var leaf = record.get('leaf');
				if (leaf) {
					var id = record.get('id');
					var text = record.get('text');
					var tabs = center;
					var tab = Ext.getCmp(id);
					if(tab == null){
						var url = 'JRainbow.pages.'+id+'Panel';
						Ext.require([url],function(){
							tab = tabs.add(Ext.widget('panel', {  
								id : id,
		                        title: text,  
		                        closable: true,
		                        items : [{
		                        	xtype : id+'Panel',
		                        	title : text,
		                        	pageSize : 30
		                        }]
		                    })); 
							tabs.setActiveTab(tab);
						}); 
					}
					
                    tabs.setActiveTab(tab);  
				} 
			}
		} 
    });
    var center = new Ext.TabPanel({
        region: 'center',
        activeTab: 0,
        items: [{
            title: '主页',
            authHeight: true,
            closable: false,
            html: '主页内容'
        }]
    });
    var south = new Ext.Panel({
        id: 'south',
        autoWidth: true,
        heigth: 200,
        frame: true,
        region: 'south',
        html: '<div id="footer" style="margin:0 auto;text-align:center;background-color:#157FCC"><span >Copyright © 2013-2014 Framlife.cn</span></div>'
    });
    var viewport = new Ext.Viewport({
        layout: "border",
        items: [north, south, west, center]
    });
});